<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class users_model extends CI_Model {

	function get_all_users(){
		$this->db->select('id, first_name, last_name');
		$query = $this->db->get('users');
		return $query->result();
	}


	function update_password($data){
		$this->db->where('id', $data['id']);
		$this->db->update('users', $data);
	}

	function validate_current_password($data){
		$this->db->where('id', $data['id']);
		$this->db->where('password', $data['password']);
		$query=$this->db->get('users');
		if ($query->num_rows == 1) {
			return true;
		}else{
			return false;
		}
	}

	function get_user_info($users_array){
		if (count($users_array) > 0 && is_array($users_array)) {
			$ids = implode(",", $users_array);
			$query = $this->db->query("SELECT email, CONCAT(first_name, ' ', last_name) as name FROM users WHERE id IN (". $ids . ")");
			return $query->result();
		}
	}


}

/* End of file users_model.php */
/* Location: ./application/models/users_model.php */